package Month09.day0914;

public class TestInnerClass {
    public int a;
    public static int a2;
    public String b;
    public float c;
     //这是一个普通内部类
    public  static void print1(){
        System.out.println("12345");
     }
    class InnerClass1{
        int a = 10;
        public void print(){
            TestInnerClass.this.a = 20;
            System.out.println(a);
            System.out.println(TestInnerClass.this.a);
        }
    }

    //这是一个静态内部类
    static class InnerClass2{
        int a;
        int a2 = 20;
        public void print(){
            TestInnerClass.a2 = 10;
            System.out.println(TestInnerClass.a2);
        }
    }

    //局部内部类：构造代码块中
    {
         class InnerClass3{
         //static int k = 10;
         public void print(){
             System.out.println(a);
         }
         }
    }

    //局部内部类：静态代码块中
    static {
        class InnerClass4 {
            //static int a = 20;
            public void print(){
                //System.out.println(a);
            }
        }
    }

    //局部内部类：方法中
    public void InnerClass3(){
        class InnerClass5{
            //static int v = 30;
            public void print(){
                System.out.println(a);
            }

        }
        InnerClass5 s1 = new InnerClass5();
        s1.print();
    }

    public static void main(String[] args) {
        /* //这是写法一
        InnerClass1 test1 = new TestInnerClass().new InnerClass1();*/
        /*TestInnerClass s1 = new TestInnerClass();
        InnerClass1 test2 = s1.new InnerClass1();
        test2.print();
        InnerClass2 test3 = new InnerClass2();
        test3.print();
        */
        TestInnerClass s1 = new TestInnerClass();

    }
}
